package thread;

//守护线程

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread rose = new Thread("rose") {
            public void run() {
                System.out.println(getName() + ":jack?");
                for (int i = 0; i < 5; i++) {
                    System.out.println(getName() + ":let me go!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    }
                }
                System.out.println(getName() + ":啊啊啊啊啊啊啊啊啊~");
                System.out.println("扑通~");
            }
        };


        Thread jack = new Thread("jack") {
            public void run() {
                while (true) {
                    System.out.println(getName() + "you jump! i jump!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                    }
                }
            }
        };


        rose.start();

        jack.setDaemon(true); //jack变成守护线程
        jack.start();

        while (true);

    }
}
